package com.learn.controller;

import com.learn.base.ApiResult;
import com.learn.dto.req.QueryProductListReq;
import com.learn.dto.resp.QueryProductListResp;
import com.learn.service.ProductService;
import com.learn.utils.GlobalTokenUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping (value = "product")
@Service
public class ProductController
{
	@Autowired
	private ProductService productService;

	//新增產品
	//    @PostMapping("/add")
	//    public ApiResult<Boolean> addProduct(@RequestBody AddProductReq req){
	//        log.info("addProduct 的請求參數是 {}" , req);
	//        log.info ("======{}", GlobalTokenUtil.getUserAccount ());
	//        return productService.saveAddProduct(req);
	//    }
	//
	//    //刪除產品
	//    @PostMapping("/delete")
	//    public ApiResult<Boolean> deleteProduct(@RequestBody DeleteProductReq req){
	//        log.info("deleteProduct 的請求參數是 {}" , req);
	//        log.info ("======{}", GlobalTokenUtil.getUserAccount ());
	//        return productService.saveDeleteProduct(req);
	//    }
	//
	    //列表查詢
	    @PostMapping ("/list")
	    public ApiResult<QueryProductListResp> queryProductList(@RequestBody QueryProductListReq req){
	        log.info("queryProductList 的請求參數是 {}" , req);
	        log.info ("======{}", GlobalTokenUtil.getUserAccount ());
	        return productService.saveQueryProductList(req);
	    }
	//
	//    //詳情查詢
	//    @PostMapping("/detail")
	//    public ApiResult<QueryProductDetailResp> queryProductDetail(@RequestBody QueryProductDetailReq req){
	//        log.info("queryProductDetail 的請求參數是 {}" , req);
	//        log.info ("======{}", GlobalTokenUtil.getUserAccount ());
	//        return productService.saveQueryProductDetail(req);
	//    }
	//
	//    //更新產品
	//    @PostMapping("/update")
	//    public ApiResult<Boolean> updateProduct(@RequestBody UpdateProductReq req){
	//        log.info("updateProduct 的請求參數是 {}" , req);
	//        log.info ("======{}", GlobalTokenUtil.getUserAccount ());
	//        return productService.saveUpdateProduct(req);
	//    }

}
